package com.oydsoft.service.system.impl;


import com.oydsoft.api.system.S03Service;
import com.oydsoft.common.model.BaseApiService;
import com.oydsoft.common.model.BaseResponse;
import com.oydsoft.dto.system.dto.S03Dto;
import com.oydsoft.dto.system.po.S03;
import com.oydsoft.dto.system.vo.S03Vo;
import com.oydsoft.service.system.mapper.S03Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.List;
@RestController
@Transactional
public class S03ServiceImpl extends BaseApiService implements S03Service {

    @Autowired
    S03Mapper s03Mapper;

    @Override
    public BaseResponse<List<S03Vo>> getList(S03Dto s03Dto) {
        List<S03Vo> s03List = s03Mapper.getS03List(s03Dto);
        return setResultSuccess(s03List);
    }

    @Override
    public BaseResponse<List<S03>> read(String id) {
        S03 s03 = s03Mapper.selectById(id);
        return setResultSuccess(s03);
    }

    @Override
    public BaseResponse<List<S03>> add(@RequestBody S03 s03) {
        int insert = s03Mapper.insert(s03);
        return setResultSuccess("新增成功");
    }

    @PreAuthorize("hasAuthority('s03:list')")
    @Override
    public BaseResponse<List<S03>> update(@RequestBody S03 s03) {
        s03Mapper.updateById(s03);
        return setResultSuccess("更新成功");
    }

    @Override
    public BaseResponse<List<S03>> delete(String id) {
        int i = s03Mapper.deleteById(id);
        return setResultSuccess("删除成功");
    }

    @Override
    public BaseResponse<List<S03>> stop(String id) {
        S03 s03 = new S03();
        s03.setS03Id(id);
        s03.setZ0011(new BigDecimal(2));
        int i = s03Mapper.updateById(s03);
        return setResultSuccess("停用成功");
    }
}
